<?php
	require '../conn.php';
	$query = "SELECT weekhot_shop.*, shop.* FROM weekhot_shop, shop WHERE weekhot_shop.shop_id=shop.shop_id";
	$result = mysql_query($query);
	$arr = array();
	while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
	{		
		$shopId = $row['shop_id'];
		$imageQuery = "SELECT * FROM images WHERE shop_id=".$shopId;
		$imageResult = mysql_query($imageQuery);
		$imageArray = array();
		while ($imageRow = mysql_fetch_array($imageResult, MYSQL_ASSOC)) {
			$imageArray[] = $imageRow;
		}
		$row['images'] = $imageArray;
		$arr[] = $row;
	}
	
	$json_str = json_encode($arr);
	echo '{"shops":'.$json_str.'}';
?>